package com.report.controller;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.report.dto.request.PartnerReq;
import com.report.dto.response.PartnerRes;
import com.report.service.PartnerService;
import com.zmh.framework.config.BaseCommonInterface;
import com.zmh.framework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author summer
 * @date 2024-06-28 11:34
 */
@RestController
@RequestMapping("/partner")
@AllArgsConstructor
public class PartnerController implements BaseCommonInterface<PartnerReq, PartnerRes> {

    private final PartnerService partnerService;

    @Override
    public Result<String> save(@Valid PartnerReq partnerReq) {
        partnerService.savePartner(partnerReq);
        return Result.successResult();
    }

    @Override
    public Result<String> del(Integer id) {
        partnerService.removeById(id);
        return Result.successResult();
    }

    @Override
    public Result<Page<PartnerRes>> lists(PartnerReq partnerReq) {
        return Result.successResult(partnerService.lists(partnerReq));
    }

    @Override
    public Result<PartnerRes> findById(Integer id) {
        return Result.successResult(Convert.convert(PartnerRes.class,partnerService.getById(id)));
    }

    @Override
    public Result<String> batchDel(List<PartnerRes> list) {
        return null;
    }
}
